package chapter07

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test11_Op
 * Package: chapter07
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 *          Date: 2023-06-28
 *          Time: 19:22
 */

//集合常用函数
object Test11_Op {
  def main(args: Array[String]): Unit = {
    val list = List(1, 2, 5, 7, 8)

    val set = Set(12, 32, 43)

    //1.获取集合长度/大小 线性序列都可以获取到长度
    println(list.length)
    println(list.size)
    //对于set来讲 没有长度 回去他的大小
    println(set.size)

    //循环遍历
    for (elem <- list) {
      println(elem)
    }
    //foreach 遍历
    set.foreach(println)

    //迭代器
    for (elem <- list.iterator) println(elem)

    //生成字符串
    println("---------------------")
    println(list.mkString(","))

    //是否包含某个元素
    println(list.contains(1)) //true
    println(set.contains(100)) //false


  }
}
